using System.IO;
using System.Threading;
using DZTC.UselessAppEver.Core;

namespace DZTC.UselessAppEver.Base32
{
    public static class ConversionOperation
    {
        private class EncodeOperation : IConversionOperation
        {
            public void PerformConversion(FileStream input, FileStream output, CancellationToken ct,
                                          ProgressToken pt)
            {
                Base32Converter.Encode(input, output, ct, pt);
            }
        }

        private class DecodeOperation : IConversionOperation
        {
            public void PerformConversion(FileStream input, FileStream output, CancellationToken ct,
                                          ProgressToken pt)
            {
                Base32Converter.Decode(input, output, ct, pt);
            }
        }

        public static IConversionOperation CreateConversionOperation(ConversionDirection direction)
        {
            return direction == ConversionDirection.Decode
                       ? (IConversionOperation)new DecodeOperation()
                       : new EncodeOperation();
        }
    }
}